import { request } from '@/utils/request'

//保存课程信息
export const saveCourse = function (entity) {
  return request.post('/course', entity)
}

//删除课程信息
export const removeCourse = function (id) {
  return request.delete(`/course/${id}`)
}

//更新课程信息
export const updateCourse = function (id, entity) {
  return request.put(`/course/${id}`, entity)
}

//获得某个课程
export const getCourse = function (id) {
  return request.get(`/course/${id}`)
}

//分页查找全部课程
export const pageCourse = function (current, size, name = '') {
  return request.get(`/course/page?current=${current}&size=${size}&name=${name}`)
}

//关闭课程
export const closeCourse = function (id) {
  return request.put(`/course/close/${id}`)
}

//开放课程
export const openCourse = function (id) {
  return request.put(`/course/open/${id}`)
}

//结束课程
export const endCourse = function (id) {
  return request.put(`/course/end/${id}`)
}

//分页查找属于自己的课程
export const pageTeacherCourse = function (current, size, name = '') {
  return request.get(`/course/teacher/page?current=${current}&size=${size}&name=${name}`)
}